import scrapy
from mySpider.items import MyspiderUrl

class BossurlSpider(scrapy.Spider):
    name = "bossUrl"
    allowed_domains = ["www.zhipin.com"]
    start_urls = ["https://www.zhipin.com"]

    def parse(self, response):
        job_menu = response.xpath('//*[@id="main"]/div/div[1]/div/div[1]/dl[1]/div/ul/li')
        typeList = []
        spiderUrl = 'https://www.zhipin.com/web/geek/job?query=%s&city=100010000&page=%s'
        for i in job_menu:
            types = i.xpath('./div/a/text()').extract()
            for type in types:
                typeList.append(type)

        for type in typeList:
            for i in range(1, 16):
                items = MyspiderUrl()
                items['type'] = type
                items['url'] = spiderUrl % (type, i)
                yield items
